//
//  ViewController.m
//  list
//
//  Created by mac on 15/7/28.
//  Copyright (c) 2015年 iyuele. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)toplist:(id)sender {
    NSString *path = [[NSBundle mainBundle] pathForResource:@"wuti.txt" ofType:nil];
    NSString *contents = [[NSString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
    NSArray *contentsArray = [contents componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
    
//    NSString *docs = [NSHomeDirectory() stringByAppendingPathComponent:@"emoji.plist"] ;
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
    NSString *plistPath1 = [paths objectAtIndex:0];
//    NSString *docs=[plistPath1 stringByAppendingPathComponent:@"emoji.plist"];
NSString *docs = @"/Users/mac/Desktop/wuti.plist";
    NSMutableArray *arr = [[NSMutableArray alloc] init];
    
    NSInteger idx;
    for (idx = 0; idx < contentsArray.count; idx++) {
        NSString* currentContent = [contentsArray objectAtIndex:idx];
        NSArray* timeDataArr = [currentContent componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@";"]];
        NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
        [dic setObject:[timeDataArr objectAtIndex:0] forKey:@"code"];
        [dic setObject:[timeDataArr objectAtIndex:1] forKey:@"png"];
       
        [arr addObject:dic];
    }
    [arr writeToFile:docs atomically:YES];
      

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
